package com.lj.dict.result;

import com.lj.dict.entity.DictItem;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * <p>
 * 字典项表 分页结果
 * </p>
 *
 * @author luojing
 * @since 2025-01-10 11:16:54
 */
@Data
@Schema(description = "字典项表 分页结果")
public class DictItemPageResult {

    private Long id;

    @Schema(description = "字典id ")
    private Long dictId;

    @Schema(description = "字典标签 ")
    private String label;

    @Schema(description = "字典值 ")
    private String value;

    @Schema(description = "字典值类型")
    private Integer valueType;

    @Schema(description = "附加的信息 ")
    private String extendJson;

    @Schema(description = "排序 ")
    private Integer sort;

    public static DictItemPageResult of(DictItem entity) {
        if (entity == null) {
            return null;
        }
        DictItemPageResult result = new DictItemPageResult();
        result.setId(entity.getId());
        result.setDictId(entity.getDictId());
        result.setLabel(entity.getLabel());
        result.setValue(entity.getValue());
        result.setValueType(entity.getValueType().getValue());
        result.setExtendJson(entity.getExtendJson());
        result.setSort(entity.getSort());
        return result;
    }
}
